package mymodel

import (
	"devops-super/internal/model/entity"
	"github.com/gogf/gf/v2/os/gtime"
)

// AlertScene 告警场景数据传输对象
type AlertScene struct {
	Name        string `json:"name" v:"required#名称不能为空"`
	EnglishName string `json:"englishName"   orm:"english_name"   description:"英文名称"  v:"required#英文名称不能为空"`
	Type        string `json:"type" v:"required#类别标识不能为空"`
	DeptId      uint64 `json:"deptId" v:"required#所属部门不能为空"`
	Level       int    `json:"level" v:"required#级别不能为空"`
	Frequency   uint   `json:"frequency" v:"required#通知频率不能为空"`
	NoticeType  string `json:"noticeType" v:"required#通知类型不能为空"`
	Remark      string `json:"remark"`
	BindTo      int    `json:"bindTo" v:"required#绑定范围不能为空"`
	JudgeMark   string `json:"judgeMark" v:"required#判断符号不能为空"`
}

// AlertSceneResponse 告警场景响应对象
type AlertSceneResponse struct {
	Id          uint64      `json:"id"`
	Name        string      `json:"name"`
	EnglishName string      `json:"englishName"`
	Type        string      `json:"type"`
	DeptId      uint64      `json:"deptId"`
	Level       int         `json:"level"`
	Frequency   uint        `json:"frequency"`
	NoticeType  string      `json:"noticeType"`
	Remark      string      `json:"remark"`
	CreatedAt   *gtime.Time `json:"createdAt"`
	UpdatedAt   *gtime.Time `json:"updatedAt"`
	BindTo      int         `json:"bindTo"`
	JudgeMark   string      `json:"judgeMark"`
	DeptName    string      `json:"deptName"`
}

// ToEntity 将AlertScene转换为实体
func (m *AlertScene) ToEntity() *entity.AlertScene {
	return &entity.AlertScene{
		Name:        m.Name,
		EnglishName: m.EnglishName,
		Type:        m.Type,
		DeptId:      m.DeptId,
		Level:       m.Level,
		Frequency:   m.Frequency,
		NoticeType:  m.NoticeType,
		Remark:      m.Remark,
		BindTo:      m.BindTo,
		JudgeMark:   m.JudgeMark,
	}
}

// AlertPeople 告警人员数据传输对象
type AlertPeople struct {
	Name             string `json:"name" v:"required#姓名不能为空"`
	DeptId           uint64 `json:"deptId" v:"required#所属部门不能为空"`
	Phone            string `json:"phone" v:"required#手机号不能为空"`
	Email            string `json:"email" v:"required#邮箱不能为空"`
	Wechat           string `json:"wechat"`
	Language         string `json:"language" v:"required#使用语言不能为空"`
	Remark           string `json:"remark"`
	ReceiveFrequency int    `json:"receiveFrequency" v:"required#接收频率限制不能为空"`
}

// AlertPeopleResponse 告警人员响应对象
type AlertPeopleResponse struct {
	Id               uint64      `json:"id"`
	Name             string      `json:"name"`
	DeptId           uint64      `json:"deptId"`
	Phone            string      `json:"phone"`
	Email            string      `json:"email"`
	Wechat           string      `json:"wechat"`
	Language         string      `json:"language"`
	Remark           string      `json:"remark"`
	ReceiveFrequency int         `json:"receiveFrequency"`
	CreatedAt        *gtime.Time `json:"createdAt"`
	UpdatedAt        *gtime.Time `json:"updatedAt"`
	DeptName         string      `json:"deptName"`
}

// ToEntity 将AlertPeople转换为实体
func (m *AlertPeople) ToEntity() *entity.AlertPeople {
	return &entity.AlertPeople{
		Name:             m.Name,
		DeptId:           m.DeptId,
		Phone:            m.Phone,
		Email:            m.Email,
		Wechat:           m.Wechat,
		Language:         m.Language,
		Remark:           m.Remark,
		ReceiveFrequency: m.ReceiveFrequency,
	}
}

// AlertLog 告警日志数据传输对象
type AlertLog struct {
	SceneId      int64  `json:"sceneId" v:"required#告警场景id不能为空"`
	Level        uint   `json:"level" v:"required#等级不能为空"`
	BindTo       int    `json:"bindTo" v:"required#绑定范围不能为空"`
	BindId       string `json:"bindId" v:"required#绑定范围id不能为空"`
	DeptId       int64  `json:"deptId" v:"required#部门id不能为空"`
	Detail       string `json:"detail" description:"详细数据"`
	Sampletime   int64  `json:"sampletime" v:"required#采样时间不能为空"`
	HandleStatus int    `json:"handleStatus" description:"处理状态 0未处理 1处理中 2处理完成"`
	HandRemark   string `json:"handRemark" description:"处理备注"`
}

// AlertLogResponse 告警日志响应对象
type AlertLogResponse struct {
	Id           int64       `json:"id"`
	SceneId      int64       `json:"sceneId"`
	Level        uint        `json:"level"`
	BindTo       int         `json:"bindTo"`
	BindId       string      `json:"bindId"`
	DeptId       int64       `json:"deptId"`
	Detail       string      `json:"detail"`
	Sampletime   int64       `json:"sampletime"`
	HandleStatus int         `json:"handleStatus"`
	HandleTime   *gtime.Time `json:"handleTime"`
	HandRemark   string      `json:"handRemark"`
	CreatedAt    *gtime.Time `json:"createdAt"`
	UpdatedAt    *gtime.Time `json:"updatedAt"`
	DeptName     string      `json:"deptName"`
	SceneName    string      `json:"sceneName"`
}

// ToEntity 将AlertLog转换为实体
func (m *AlertLog) ToEntity() *entity.AlertLogDemo {
	return &entity.AlertLogDemo{
		SceneId:      m.SceneId,
		Level:        m.Level,
		BindTo:       m.BindTo,
		BindId:       m.BindId,
		DeptId:       m.DeptId,
		Detail:       m.Detail,
		Sampletime:   m.Sampletime,
		HandleStatus: m.HandleStatus,
		HandRemark:   m.HandRemark,
	}
}

// AlertPeopleMsg 告警通知日志数据传输对象
type AlertPeopleMsg struct {
	AlertLogId uint64 `json:"alertLogId" v:"required#告警日志id不能为空"`
	PeopleId   int64  `json:"peopleId" v:"required#人员id不能为空"`
	Msg        string `json:"msg" v:"required#发送的消息不能为空"`
	NoticeType string `json:"noticeType" v:"required#通知方法不能为空"`
	Status     int    `json:"status" v:"required#通知状态不能为空"`
	StatusMsg  string `json:"statusMsg" description:"失败消息返回理由"`
	DeptId     int64  `json:"deptId" v:"required#部门id不能为空"`
}

// AlertPeopleMsgResponse 告警通知日志响应对象
type AlertPeopleMsgResponse struct {
	Id         int64       `json:"id"`
	AlertLogId uint64      `json:"alertLogId"`
	PeopleId   int64       `json:"peopleId"`
	Msg        string      `json:"msg"`
	NoticeType string      `json:"noticeType"`
	Status     int         `json:"status"`
	StatusMsg  string      `json:"statusMsg"`
	CreatedAt  *gtime.Time `json:"createdAt"`
	UpdatedAt  *gtime.Time `json:"updatedAt"`
	DeptId     int64       `json:"deptId"`
	DeptName   string      `json:"deptName"`
}

// ToEntity 将AlertPeopleMsg转换为实体
func (m *AlertPeopleMsg) ToEntity() *entity.AlertPeopleMsgsDemo {
	return &entity.AlertPeopleMsgsDemo{
		AlertLogId: m.AlertLogId,
		PeopleId:   m.PeopleId,
		Msg:        m.Msg,
		NoticeType: m.NoticeType,
		Status:     m.Status,
		StatusMsg:  m.StatusMsg,
		DeptId:     m.DeptId,
	}
}
